package com.jiandian;

import com.jiandian.exception.ActivememberException;
import com.jiandian.exception.SignPrizeException;
import com.jiandian.exception.SignPrizeLogException;
import com.jiandian.exception.SuppleException;
import com.jiandian.util.BaseResult;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.*;

/**
 * @author lik
 */
@Slf4j
@RestControllerAdvice
public class ExceptionControllerAdvice {
    @ResponseStatus(HttpStatus.OK)
    @ExceptionHandler(ActivememberException.class)
    public BaseResult activememberException(Exception ex){
        log.error(ex.getMessage());
        return new BaseResult(400,ex.getMessage());
    }

    @ResponseStatus(HttpStatus.OK)
    @ExceptionHandler(SignPrizeException.class)
    public BaseResult signPrizeException(Exception ex){
        log.error(ex.getMessage());
        return new BaseResult(400,ex.getMessage());
    }

    @ResponseStatus(HttpStatus.OK)
    @ExceptionHandler(SignPrizeLogException.class)
    public BaseResult signPrizeLogException(Exception ex){
        log.error(ex.getMessage());
        return new BaseResult(400,ex.getMessage());
    }

    @ResponseStatus(HttpStatus.OK)
    @ExceptionHandler(SuppleException.class)
    public BaseResult suppleException(Exception ex){
        log.error(ex.getMessage());
        return new BaseResult(400,ex.getMessage());
    }
}
